from datetime import datetime


def calculate(operation: str) -> float:
    return eval(operation)


def get_current_time(location:str) -> str:
    now = datetime.now()
    return now.strftime("%Y-%m-%d, %H:%M:%S")


def get_week_time(location:str) -> str:
    now = datetime.now()
    week = now.weekday()
    return f"今天星期{week+1}"


available_actions = {
    "calculate": calculate,
    "get_current_time": get_current_time,
    "get_week_time": get_week_time,
}
if "__main__" == __name__:
    print(calculate("8*8"))
    print(get_current_time())
    print(get_week_time())

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_current_time",
            "description": "获取当前时间",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "当前时区, 例如. 南京",
                    }
                },
                "required": ["location"],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "get_week_time",
            "description": "获取今天星期几",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "当前时区, 例如. 东京",
                    }
                },
                "required": ["location"],
            },
        },
    },
    {
        "type": "function",
        "function": {
            "name": "calculate",
            "description": "计算两个值的结果，必要是考虑小数。",
            "parameters": {
                "type": "object",
                "properties": {
                    "operation": {
                        "type": "string",
                        "description": "3乘以9, 例如：3*9",
                    }
                },
                "required": ["operation"],
            },
        },
    },
]
